<?php
/**
 *
 * 版权所有：恰维网络<qwadmin.qiawei.com>
 * 作    者：寒川<hanchuan@qiawei.com>
 * 日    期：2015-09-18
 * 版    本：1.0.0
 * 功能说明：个人中心控制器。
 *
 **/

namespace Admin\Controller;

class PersonalController extends ComController
{

    public function profile()
    {

        $member = M('member')->where('uid=' . $this->USER['uid'])->find();
        $this->assign('nav', array('Personal', 'profile', ''));//导航
        $this->assign('member', $member);
        $this->display();
    }

    public function update()
    {

        $uid = $this->USER['uid'];
        if($uid === 1){
            $password = isset($_POST['password']) ? trim($_POST['password']) : false;
            if ($password) {
                $data['password'] = password($password);
            }

            $head = I('post.head', '', 'strip_tags');
            if ($head <> '') {
                $data['head'] = $head;
            }
        }else{

            $password = isset($_POST['password']) ? trim($_POST['password']) : false;
            if ($password) {
                $data['password'] = password($password);
            }

            $head = I('post.head', '', 'strip_tags');
            if ($head <> '') {
                $data['head'] = $head;
            }

            $data['content'] = isset($_POST['content']) ? trim($_POST['content']) : '';
            $data['phone'] = isset($_POST['phone']) ? trim($_POST['phone']) : '';
        }
        $data['update_time'] = time();
        $Model = M('member');
        $Model->data($data)->where("uid=$uid")->save();
        if($Model!==false){

            addlog('修改个人资料');
            $this->success('操作成功！');
        }else{
            addlog('修改个人资料');
            $this->success('操作失败！');
        }


    }
}